package com.xbongbong.saas.script.tempenum;

import com.xbongbong.i18n.util.I18nMessageUtil;
import com.xbongbong.paas.enums.DateTimeEnum;
import com.xbongbong.paas.enums.DefaultTypeEnum;
import com.xbongbong.paas.field.DefaultAttrPoJo;
import com.xbongbong.paas.field.FieldAttrEntity;
import com.xbongbong.paas.field.ItemPoJo;
import com.xbongbong.paas.field.LinkDetailPojo;
import com.xbongbong.paas.field.TuningPoJo;
import com.xbongbong.pro.enums.DistributorMarkEnum;
import com.xbongbong.pro.enums.SaasMarkEnum;
import com.xbongbong.paas.field.SaasParticularAttributePoJo;
import com.xbongbong.saas.constant.StringConstant;
import com.xbongbong.saas.enums.RedundantTemplateTypeEnum;
import com.xbongbong.saas.enums.XbbRefTypeEnum;
import com.xbongbong.saas.enums.business.DistributorCommunicateEnum;
import com.xbongbong.saas.enums.dictionary.CommunicateTypeEnum;
import com.xbongbong.saas.script.help.InitExplainsHelper;
import lombok.Getter;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

/**
 * 经销商跟进记录
 * @author xinpeng.jiang
 * @date 2020/12/21 15:43
 * @version 1.0
 * @since V1.0
 */
@Getter
public enum TempCustomerCommunicateDistributorEnum {
    /**
     * 经销商跟进记录
     */
    BASE_INFO(DistributorCommunicateEnum.BASE_INFO),
    DISTRIBUTOR_NAME(DistributorCommunicateEnum.DISTRIBUTOR_NAME),
    CONTACT_ARRAY(DistributorCommunicateEnum.CONTACT_ARRAY),
    TYPE(DistributorCommunicateEnum.TYPE),
    COMMUNICATE_TIME(DistributorCommunicateEnum.COMMUNICATE_TIME),
    COMMUNICATE_BUSINESS(DistributorCommunicateEnum.COMMUNICATE_BUSINESS),
    MEMO(DistributorCommunicateEnum.MEMO),
    VIDEO(DistributorCommunicateEnum.VIDEO),
    ADDRESS(DistributorCommunicateEnum.ADDRESS),
    IMAGES(DistributorCommunicateEnum.IMAGES),
    FILE(DistributorCommunicateEnum.FILE),

//    ASSOCIATED_INFO(DistributorCommunicateEnum.ASSOCIATED_INFO),
//    IF_REMIND(DistributorCommunicateEnum.IF_REMIND),
//    NEXT_COMMUNICATE_TIME(DistributorCommunicateEnum.NEXT_COMMUNICATE_TIME),
//    NOTIFY_TYPE(DistributorCommunicateEnum.NOTIFY_TYPE),
//    NOTIFY_TIME(DistributorCommunicateEnum.NOTIFY_TIME),
//    NEXT_NOTIFY_MEMO(DistributorCommunicateEnum.NEXT_NOTIFY_MEMO),

    SYSTEM_INFO(DistributorCommunicateEnum.SYSTEM_INFO),
    CREATOR_ID(DistributorCommunicateEnum.CREATOR_ID),

    ADD_TIME(DistributorCommunicateEnum.ADD_TIME),
    UPDATE_TIME(DistributorCommunicateEnum.UPDATE_TIME),
    AUTO_GEN(DistributorCommunicateEnum.AUTO_GEN),

    USER_ID(DistributorCommunicateEnum.USER_ID),
    USER_NAME(DistributorCommunicateEnum.USER_NAME),
    USER_AVATAR(DistributorCommunicateEnum.USER_AVATAR),
    DISTRIBUTOR_NAME_LINK_TEXT(DistributorCommunicateEnum.DISTRIBUTOR_NAME_LINK_TEXT),
    CONTACT_NAME_LINK_TEXT(DistributorCommunicateEnum.CONTACT_NAME_LINK_TEXT),
    FINISH_COMMUNICATE_PLAN_LINK_TEXT(DistributorCommunicateEnum.FINISH_COMMUNICATE_PLAN_LINK_TEXT),
    COMMUNICATE_BUSINESS_TYPE(DistributorCommunicateEnum.COMMUNICATE_BUSINESS_TYPE),
    COMMUNICATE_BUSINESS_LINK_TEXT(DistributorCommunicateEnum.COMMUNICATE_BUSINESS_LINK_TEXT),
    AT_USERNAME(DistributorCommunicateEnum.AT_USERNAME),
    ;
    private DistributorCommunicateEnum anEnum;

    TempCustomerCommunicateDistributorEnum(DistributorCommunicateEnum anEnum) {
        this.anEnum = anEnum;
    }

    public static List<TempCustomerCommunicateDistributorEnum> getAllEnum() {
        List<TempCustomerCommunicateDistributorEnum> list = new ArrayList<>();
        Collections.addAll(list, values());
        return list;
    }

    /**
     * 初始化跟进方式
     *
     * @param fieldAttrEntity 字段解释实体--saas专用
     */
    public static void initType(FieldAttrEntity fieldAttrEntity){
        fieldAttrEntity.setItems(InitExplainsHelper.setCombItemByEnum(CommunicateTypeEnum.class, fieldAttrEntity.getFieldType()));
        fieldAttrEntity.setDictionaryFlag(1);
        fieldAttrEntity.setIsForbidden(0);
    }

    /**
     * 初始化拜访时间
     *
     * @param fieldAttrEntity 字段解释实体--saas专用
     */
    public static void initCommunicateTime(FieldAttrEntity fieldAttrEntity){
        fieldAttrEntity.setDateType(DateTimeEnum.DATETIME.getType());
        DefaultAttrPoJo defaultAttrPoJo = new DefaultAttrPoJo();
        defaultAttrPoJo.setDefaultType(DefaultTypeEnum.TODAY.getAlias());
        fieldAttrEntity.setDefaultAttr(defaultAttrPoJo);
        fieldAttrEntity.setIsForbidden(0);
    }

    /**
     * 初始化关联客户
     *
     * @param fieldAttrEntity 字段解释实体--saas专用
     */
        public static void initDistributorName(FieldAttrEntity fieldAttrEntity) {
        fieldAttrEntity.setLinkedType(RedundantTemplateTypeEnum.CUSTOMER.getCode());
        fieldAttrEntity.setLinkedText(DISTRIBUTOR_NAME_LINK_TEXT.anEnum.getAttr());
        SaasParticularAttributePoJo saasParticularAttributePoJo = new SaasParticularAttributePoJo();
        saasParticularAttributePoJo.setMultiCheck(false);
        saasParticularAttributePoJo.setRelyMode("customer");
        saasParticularAttributePoJo.setRelyType("base");
        fieldAttrEntity.setSaasParticularAttributePoJo(saasParticularAttributePoJo);
        LinkDetailPojo linkDetailPojo = new LinkDetailPojo();
        linkDetailPojo.setBusinessType(XbbRefTypeEnum.CUSTOMER_MANAGEMENT.getCode());
        linkDetailPojo.setSubBuisenssType(XbbRefTypeEnum.CUSTOMER_MANAGEMENT.getCode());
        linkDetailPojo.setSaasMark(SaasMarkEnum.SAAS.getCode());
        linkDetailPojo.setAttr(DISTRIBUTOR_NAME.getAnEnum().getAttr());
        fieldAttrEntity.setDistributorMark(DistributorMarkEnum.DISTRIBUTOR.getCode());
        fieldAttrEntity.setLinkDetail(linkDetailPojo);
        fieldAttrEntity.setIsForbidden(0);
    }

    /**
     * 初始化客户状态
     *
     * @param fieldAttrEntity 字段解释实体--saas专用
     */
    /*public static void initCustomerStatus(FieldAttrEntity fieldAttrEntity){
        SaasParticularAttributePoJo saasParticularAttributePoJo = new SaasParticularAttributePoJo();
        saasParticularAttributePoJo.setRelyMode("customer");
        saasParticularAttributePoJo.setRelyType("relied");
        fieldAttrEntity.setSaasParticularAttributePoJo(saasParticularAttributePoJo);
    }*/

    /**
     * 初始化关联联系人
     *
     * @param fieldAttrEntity 字段解释实体--saas专用
     */
    public static void initContactArray(FieldAttrEntity fieldAttrEntity) {
        fieldAttrEntity.setLinkedType(RedundantTemplateTypeEnum.CONTACT.getCode());
        fieldAttrEntity.setLinkedText(CONTACT_NAME_LINK_TEXT.anEnum.getAttr());
        fieldAttrEntity.setDistributorMark(DistributorMarkEnum.DISTRIBUTOR.getCode());
        SaasParticularAttributePoJo saasParticularAttributePoJo = new SaasParticularAttributePoJo();
        saasParticularAttributePoJo.setMultiCheck(true);
        saasParticularAttributePoJo.setRelyMode("customer");
        saasParticularAttributePoJo.setRelyType("relied");
        saasParticularAttributePoJo.setRelyBusiness(XbbRefTypeEnum.CUSTOMER_MANAGEMENT.getCode());
        fieldAttrEntity.setSaasParticularAttributePoJo(saasParticularAttributePoJo);
    }

    /**
     * 初始化关联合同
     *
     * @param fieldAttrEntity 字段解释实体--saas专用
     */
    public static void initContractId(FieldAttrEntity fieldAttrEntity) {
        fieldAttrEntity.setLinkedType(RedundantTemplateTypeEnum.CONTRACT.getCode());
//        fieldAttrEntity.setLinkedText(CONTRACT_NAME_LINK_TEXT.anEnum.getAttr());
        SaasParticularAttributePoJo saasParticularAttributePoJo = new SaasParticularAttributePoJo();
        saasParticularAttributePoJo.setMultiCheck(false);
        fieldAttrEntity.setSaasParticularAttributePoJo(saasParticularAttributePoJo);
    }

    /**
     * 初始化跟进业务
     *
     * @param fieldAttrEntity 字段属性实体
     * @author long.rao
     * @date 2019-02-12 14:09
     */
    public static void initCommunicateBusiness(FieldAttrEntity fieldAttrEntity) {
        // todo：订货单
        List<ItemPoJo> itemPoJos = new ArrayList<>();
        ItemPoJo itemPoJo = new ItemPoJo();
        itemPoJo.setText(XbbRefTypeEnum.ORDER.getName());
        itemPoJo.setValue(XbbRefTypeEnum.CONTRACT.getCode() + "");
        itemPoJo.setChecked(true);
        itemPoJos.add(itemPoJo);
        fieldAttrEntity.setItems(itemPoJos);
        SaasParticularAttributePoJo saasParticularAttributePoJo = new SaasParticularAttributePoJo();
        saasParticularAttributePoJo.setRelyMode("customer");
        saasParticularAttributePoJo.setRelyType("relied");
        saasParticularAttributePoJo.setRelyBusiness(XbbRefTypeEnum.CUSTOMER_MANAGEMENT.getCode());
        LinkDetailPojo linkDetailPojo = new LinkDetailPojo();
        linkDetailPojo.setBusinessType(XbbRefTypeEnum.CONTRACT.getCode());
        linkDetailPojo.setSubBuisenssType(XbbRefTypeEnum.CONTRACT.getCode());
        linkDetailPojo.setSaasMark(SaasMarkEnum.SAAS.getCode());
        linkDetailPojo.setAttr(COMMUNICATE_BUSINESS.getAnEnum().getAttr());
        fieldAttrEntity.setDistributorMark(DistributorMarkEnum.DISTRIBUTOR.getCode());
        fieldAttrEntity.setLinkDetail(linkDetailPojo);
        fieldAttrEntity.setSaasParticularAttributePoJo(saasParticularAttributePoJo);
    }

    /**
     * 初始化提醒
     *
     * @param fieldAttrEntity 实体
     */
//    public static void initNotifyType(FieldAttrEntity fieldAttrEntity) {
//        List<ItemPoJo> itemPoJos = new ArrayList<>();
//        ItemPoJo itemPoJo2 = new ItemPoJo();
//        itemPoJo2.setText(CommunicatePlanNotifyTypeEnum.ADVANCE_ONE_QUARTER_HOUR.getAlias());
//        itemPoJo2.setValue(CommunicatePlanNotifyTypeEnum.ADVANCE_ONE_QUARTER_HOUR.getCode().toString());
//        itemPoJo2.setChecked(true);
//        itemPoJos.add(itemPoJo2);
//        ItemPoJo itemPoJo3 = new ItemPoJo();
//        itemPoJo3.setText(CommunicatePlanNotifyTypeEnum.ADVANCE_ONE_HOUR.getAlias());
//        itemPoJo3.setValue(CommunicatePlanNotifyTypeEnum.ADVANCE_ONE_HOUR.getCode().toString());
//        itemPoJo3.setChecked(false);
//        itemPoJos.add(itemPoJo3);
//        ItemPoJo itemPoJo4 = new ItemPoJo();
//        itemPoJo4.setText(CommunicatePlanNotifyTypeEnum.ADVANCE_ONE_DAY.getAlias());
//        itemPoJo4.setValue(CommunicatePlanNotifyTypeEnum.ADVANCE_ONE_DAY.getCode().toString());
//        itemPoJo4.setChecked(false);
//        itemPoJos.add(itemPoJo4);
//        ItemPoJo itemPoJo5 = new ItemPoJo();
//        itemPoJo5.setText(CommunicatePlanNotifyTypeEnum.ADVANCE_THREE_DAY.getAlias());
//        itemPoJo5.setValue(CommunicatePlanNotifyTypeEnum.ADVANCE_THREE_DAY.getCode().toString());
//        itemPoJo5.setChecked(false);
//        itemPoJos.add(itemPoJo5);
//        ItemPoJo itemPoJo6 = new ItemPoJo();
//        itemPoJo6.setText(CommunicatePlanNotifyTypeEnum.ADVANCE_ONE_WEEK.getAlias());
//        itemPoJo6.setValue(CommunicatePlanNotifyTypeEnum.ADVANCE_ONE_WEEK.getCode().toString());
//        itemPoJo6.setChecked(false);
//        itemPoJos.add(itemPoJo6);
//        ItemPoJo itemPoJo7 = new ItemPoJo();
//        itemPoJo7.setText(CommunicatePlanNotifyTypeEnum.CUSTOM_TIME.getAlias());
//        itemPoJo7.setValue(CommunicatePlanNotifyTypeEnum.CUSTOM_TIME.getCode().toString());
//        itemPoJo7.setChecked(false);
//
//        List<String> fieldMap = new ArrayList<>();
//        fieldMap.add(NOTIFY_TIME.anEnum.getAttr());
//        itemPoJo7.setFieldMap(fieldMap);
//        itemPoJos.add(itemPoJo7);
//        fieldAttrEntity.setItems(itemPoJos);
//        DefaultAttrPoJo defaultAttrPoJo = new DefaultAttrPoJo();
//        defaultAttrPoJo.setDefaultType(StringConstant.CUSTOM);
//        defaultAttrPoJo.setDefaultValue("");
//        fieldAttrEntity.setDefaultAttr(defaultAttrPoJo);
//    }

    /**
     * 初始化下次拜访时间
     *
     * @param fieldAttrEntity 字段解释实体--saas专用
     */
    public static void initNextCommunicateTime(FieldAttrEntity fieldAttrEntity){
        fieldAttrEntity.setDateType("yyyy-MM-dd HH:mm");
    }

    /**
     * 初始化下次提醒时间
     *
     * @param fieldAttrEntity 字段解释实体--saas专用
     */
    public static void initNotifyTime(FieldAttrEntity fieldAttrEntity){
        fieldAttrEntity.setDateType("yyyy-MM-dd HH:mm");
    }

    /**
     * 初始化下次提醒
     *
     * @param fieldAttrEntity 字段解释实体--saas专用
     */
//    public static void initIfRemind(FieldAttrEntity fieldAttrEntity){
//        List<String> switchMap = new ArrayList<>();
//        switchMap.add(NEXT_COMMUNICATE_TIME.anEnum.getAttr());
//        switchMap.add(NOTIFY_TYPE.anEnum.getAttr());
//        switchMap.add(NEXT_NOTIFY_MEMO.anEnum.getAttr());
//        fieldAttrEntity.setSwitchMap(switchMap);
//    }

    /**
     * 初始化位置字段
     *
     * @param fieldAttrEntity 字段解释实体--saas专用
     */
    public static void initAddress(FieldAttrEntity fieldAttrEntity) {
        fieldAttrEntity.setLocationCenterFlag(0);
        fieldAttrEntity.setLocationCenter(new ArrayList<>());
        TuningPoJo tuningPoJo = new TuningPoJo();
        tuningPoJo.setEnable(1);
        tuningPoJo.setRadius(1000);
        fieldAttrEntity.setTuning(tuningPoJo);
    }
    public static void initCreatorId(FieldAttrEntity fieldAttrEntity) {
        fieldAttrEntity.setEditable(0);
        fieldAttrEntity.setUnableEditMemo(I18nMessageUtil.getMessage(StringConstant.AUTO_GEN_FIELD));
    }
    public static void initAddTime(FieldAttrEntity fieldAttrEntity) {
        fieldAttrEntity.setEditable(0);
        fieldAttrEntity.setUnableEditMemo(I18nMessageUtil.getMessage(StringConstant.AUTO_GEN_FIELD));
    }
    public static void initUpdateTime(FieldAttrEntity fieldAttrEntity) {
        fieldAttrEntity.setEditable(0);
        fieldAttrEntity.setUnableEditMemo(I18nMessageUtil.getMessage(StringConstant.AUTO_GEN_FIELD));
    }

    public static void initMemo(FieldAttrEntity fieldAttrEntity) {
        fieldAttrEntity.setIsForbidden(0);
        fieldAttrEntity.setEditForbidden(0);
        fieldAttrEntity.setAdvancedSetHide(1);
        fieldAttrEntity.setLinkedText(AT_USERNAME.anEnum.getAttr());
        fieldAttrEntity.setDefaultName(DistributorCommunicateEnum.MEMO.getAttrName());
    }
}
